package org.zcl.govern.server.node.master;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * 服务治理平台的Master节点
 * @author zhaocongliang
 */
public class MasterNode {

    private static final Logger LOGGER = LoggerFactory.getLogger(MasterNode.class);
    /**
     * Controller候选人
     */
    private ControllerCandidate controllerCandidate;

    private MasterNetworkManager masterNetworkManager;

    /**
     * master节点的构造函数
     */
    public MasterNode() {
        this.masterNetworkManager = new MasterNetworkManager();
        this.controllerCandidate = new ControllerCandidate(masterNetworkManager);
    }

    /**
     * 启动master节点
     */
    public void start() {
        // 等待排在这个节点之后的master节点来连接自己
        masterNetworkManager.waitAfterMasterNodesConnect();
        // 主动去连接排在自己之前的master节点
        masterNetworkManager.connectBeforeMasterNodes();
    }

}
